<?php echo $header; ?>

<?php
  // Create the string the md5 hash is calculated from, we decode the urls so they are plain before the calculation
  $md5ValuesStd = $quickpay_protocol . $quickpay_msgtype . $quickpay_merchant . $quickpay_language . $order_id . $amount . $currency . htmlspecialchars_decode($quickpay_continueurl) . htmlspecialchars_decode($quickpay_cancelurl) . htmlspecialchars_decode($quickpay_callbackurl) . $quickpay_autocapture . $quickpay_cardtypelock . $quickpay_splitpayment . $quickpay_md5check;
  $md5ValuesViabill = $quickpay_protocol . $quickpay_msgtype . $quickpay_merchant . $quickpay_language . $order_id . $amount . $currency . htmlspecialchars_decode($quickpay_continueurl) . htmlspecialchars_decode($quickpay_cancelurl) . htmlspecialchars_decode($quickpay_callbackurl) . $quickpay_autocapture . 'viabill' . $quickpay_splitpayment . $quickpay_md5check;
?>

<div id="container" class="clearfix">
    <div class="template-article w-content clearfix">
        <h3 class="title-col"><?php echo $heading_title; ?></h3>

        <form action="<?php echo $action ?>" method="post" id="quickpay_checkout">
            <input type="hidden" name="protocol" value="<?php echo $quickpay_protocol; ?>" />
            <input type="hidden" name="msgtype" value="<?php echo $quickpay_msgtype; ?>" />
            <input type="hidden" name="merchant" value="<?php echo $quickpay_merchant; ?>" />
            <input type="hidden" name="language" value="<?php echo $quickpay_language; ?>" />
            <input type="hidden" name="ordernumber" value="<?php echo $order_id; ?>" />
            <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
            <input type="hidden" name="currency" value="<?php echo $currency; ?>" />
            <input type="hidden" name="continueurl" value="<?php echo $quickpay_continueurl; ?>" />
            <input type="hidden" name="cancelurl" value="<?php echo $quickpay_cancelurl; ?>" />
            <input type="hidden" name="callbackurl" value="<?php echo $quickpay_callbackurl; ?>" />
            <input type="hidden" name="autocapture" value="<?php echo $quickpay_autocapture; ?>" />
            <input type="hidden" name="cardtypelock" value="<?php echo $quickpay_cardtypelock; ?>" />
            <input type="hidden" name="splitpayment" value="<?php echo $quickpay_splitpayment; ?>" />
            <input type="hidden" name="md5check" value="<?php echo md5($md5ValuesStd); ?>" />
            <input type="hidden" name="md5check-creditcard" value="<?php echo md5($md5ValuesStd); ?>" />
            <input type="hidden" name="md5check-viabill" value="<?php echo md5($md5ValuesViabill); ?>" />
        </form>

        <?php if($quickpay_viabill_creditcard) { ?>
        <div>
            <h2><?php echo $text_quickpay_checkout_title; ?></h2>
            <p><?php echo $text_viabill_creditcard; ?></p>
            <input type="radio" name="quickpay-flow" value="creditcard" id="quickpay-flow--creditcard" checked /> <label for="quickpay-flow--creditcard"><?php echo $text_method_creditcard; ?></label>
            <input type="radio" name="quickpay-flow" value="viabill" id="quickpay-flow--viabill" /> <label for="quickpay-flow--viabill"><?php echo $text_method_viabill; ?></label>
        </div>
        <?php } ?>
    </div>
    <!--template-article w-content-->


<script type="text/javascript">
    $(function(){
        //$('#quickpay_checkout').submit();
    });

    <?php if($quickpay_viabill_creditcard) { ?>
        $(function() {
            var md5Field = $('[name="md5check"]'),
                cardtypelockField = $('[name="cardtypelock"]');

            $('[name="quickpay-flow"]').on('change click', function () {
                var newMD5 = $('[name="md5check-' + this.value + '"]').val();
                md5Field.val(newMD5);
                cardtypelockField.val( this.value );
            });
        });
    <?php } ?>
</script>

<?php echo $footer; ?>